import axios from '@/utils/request'
import { GeometryType, Operation } from '@/views/label_segment/hooks/useLabel'

import { IPointLabel } from './types/pointLabel'

/**
 *
 * @param data FormData
 * @param data.File - File 关联文件
 * @param data.ModelId  - string 关联模型 id
 * @returns
 */
export function addLabelSegment(
  modelId: string,
  data: {
    operation: Operation
    id: string
    labelName: string
    labelType: GeometryType
    locationX: number
    locationY: number
    locationZ: number
    scaleX: number
    scaleY: number
    scaleZ: number
  }[],
) {
  return axios<IPointLabel>({
    url: `/api/3d-model/separate-label/by-model-id/${modelId}`,
    method: 'post',
    data,
  })
}

export function getLabels(modelId: string) {
  return axios<
    {
      operation: Operation
      id: string
      labelName: string
      labelType: GeometryType
      locationX: number
      locationY: number
      locationZ: number
      scaleX: number
      scaleY: number
      scaleZ: number
    }[]
  >({
    url: `/api/3d-model/separate-label/by-model-id/${modelId}`,
    method: 'get',
  })
}
